// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_float_from_datetimev2_0_part3") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part3_3_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part3_3_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part3_3_nullable values (0, "0001-12-28 00:59:00"),(1, "0001-12-28 00:59:00"),(2, "0001-12-28 00:59:00"),(3, "0001-12-28 00:59:01"),(4, "0001-12-28 00:59:01"),(5, "0001-12-28 00:59:01"),(6, "0001-12-28 00:59:59"),(7, "0001-12-28 00:59:59"),(8, "0001-12-28 00:59:59"),(9, "0001-12-28 01:00:00"),(10, "0001-12-28 01:00:00"),(11, "0001-12-28 01:00:00"),(12, "0001-12-28 01:00:01"),(13, "0001-12-28 01:00:01"),(14, "0001-12-28 01:00:01"),(15, "0001-12-28 01:00:59"),(16, "0001-12-28 01:00:59"),(17, "0001-12-28 01:00:59"),(18, "0001-12-28 01:01:00"),(19, "0001-12-28 01:01:00"),
      (20, "0001-12-28 01:01:00"),(21, "0001-12-28 01:01:01"),(22, "0001-12-28 01:01:01"),(23, "0001-12-28 01:01:01"),(24, "0001-12-28 01:01:59"),(25, "0001-12-28 01:01:59"),(26, "0001-12-28 01:01:59"),(27, "0001-12-28 01:59:00"),(28, "0001-12-28 01:59:00"),(29, "0001-12-28 01:59:00"),(30, "0001-12-28 01:59:01"),(31, "0001-12-28 01:59:01"),(32, "0001-12-28 01:59:01"),(33, "0001-12-28 01:59:59"),(34, "0001-12-28 01:59:59"),(35, "0001-12-28 01:59:59"),(36, "0001-12-28 23:00:00"),(37, "0001-12-28 23:00:00"),(38, "0001-12-28 23:00:00"),(39, "0001-12-28 23:00:01"),
      (40, "0001-12-28 23:00:01"),(41, "0001-12-28 23:00:01"),(42, "0001-12-28 23:00:59"),(43, "0001-12-28 23:00:59"),(44, "0001-12-28 23:00:59"),(45, "0001-12-28 23:01:00"),(46, "0001-12-28 23:01:00"),(47, "0001-12-28 23:01:00"),(48, "0001-12-28 23:01:01"),(49, "0001-12-28 23:01:01"),(50, "0001-12-28 23:01:01"),(51, "0001-12-28 23:01:59"),(52, "0001-12-28 23:01:59"),(53, "0001-12-28 23:01:59"),(54, "0001-12-28 23:59:00"),(55, "0001-12-28 23:59:00"),(56, "0001-12-28 23:59:00"),(57, "0001-12-28 23:59:01"),(58, "0001-12-28 23:59:01"),(59, "0001-12-28 23:59:01"),
      (60, "0001-12-28 23:59:59"),(61, "0001-12-28 23:59:59"),(62, "0001-12-28 23:59:59"),(63, "0010-01-01 00:00:00"),(64, "0010-01-01 00:00:00"),(65, "0010-01-01 00:00:00"),(66, "0010-01-01 00:00:01"),(67, "0010-01-01 00:00:01"),(68, "0010-01-01 00:00:01"),(69, "0010-01-01 00:00:59"),(70, "0010-01-01 00:00:59"),(71, "0010-01-01 00:00:59"),(72, "0010-01-01 00:01:00"),(73, "0010-01-01 00:01:00"),(74, "0010-01-01 00:01:00"),(75, "0010-01-01 00:01:01"),(76, "0010-01-01 00:01:01"),(77, "0010-01-01 00:01:01"),(78, "0010-01-01 00:01:59"),(79, "0010-01-01 00:01:59"),
      (80, "0010-01-01 00:01:59"),(81, "0010-01-01 00:59:00"),(82, "0010-01-01 00:59:00"),(83, "0010-01-01 00:59:00"),(84, "0010-01-01 00:59:01"),(85, "0010-01-01 00:59:01"),(86, "0010-01-01 00:59:01"),(87, "0010-01-01 00:59:59"),(88, "0010-01-01 00:59:59"),(89, "0010-01-01 00:59:59"),(90, "0010-01-01 01:00:00"),(91, "0010-01-01 01:00:00"),(92, "0010-01-01 01:00:00"),(93, "0010-01-01 01:00:01"),(94, "0010-01-01 01:00:01"),(95, "0010-01-01 01:00:01"),(96, "0010-01-01 01:00:59"),(97, "0010-01-01 01:00:59"),(98, "0010-01-01 01:00:59"),(99, "0010-01-01 01:01:00"),
      (100, "0010-01-01 01:01:00"),(101, "0010-01-01 01:01:00"),(102, "0010-01-01 01:01:01"),(103, "0010-01-01 01:01:01"),(104, "0010-01-01 01:01:01"),(105, "0010-01-01 01:01:59"),(106, "0010-01-01 01:01:59"),(107, "0010-01-01 01:01:59"),(108, "0010-01-01 01:59:00"),(109, "0010-01-01 01:59:00"),(110, "0010-01-01 01:59:00"),(111, "0010-01-01 01:59:01"),(112, "0010-01-01 01:59:01"),(113, "0010-01-01 01:59:01"),(114, "0010-01-01 01:59:59"),(115, "0010-01-01 01:59:59"),(116, "0010-01-01 01:59:59"),(117, "0010-01-01 23:00:00"),(118, "0010-01-01 23:00:00"),(119, "0010-01-01 23:00:00"),
      (120, "0010-01-01 23:00:01"),(121, "0010-01-01 23:00:01"),(122, "0010-01-01 23:00:01"),(123, "0010-01-01 23:00:59"),(124, "0010-01-01 23:00:59"),(125, "0010-01-01 23:00:59"),(126, "0010-01-01 23:01:00"),(127, "0010-01-01 23:01:00"),(128, "0010-01-01 23:01:00"),(129, "0010-01-01 23:01:01"),(130, "0010-01-01 23:01:01"),(131, "0010-01-01 23:01:01"),(132, "0010-01-01 23:01:59"),(133, "0010-01-01 23:01:59"),(134, "0010-01-01 23:01:59"),(135, "0010-01-01 23:59:00"),(136, "0010-01-01 23:59:00"),(137, "0010-01-01 23:59:00"),(138, "0010-01-01 23:59:01"),(139, "0010-01-01 23:59:01"),
      (140, "0010-01-01 23:59:01"),(141, "0010-01-01 23:59:59"),(142, "0010-01-01 23:59:59"),(143, "0010-01-01 23:59:59"),(144, "0010-01-28 00:00:00"),(145, "0010-01-28 00:00:00"),(146, "0010-01-28 00:00:00"),(147, "0010-01-28 00:00:01"),(148, "0010-01-28 00:00:01"),(149, "0010-01-28 00:00:01"),(150, "0010-01-28 00:00:59"),(151, "0010-01-28 00:00:59"),(152, "0010-01-28 00:00:59"),(153, "0010-01-28 00:01:00"),(154, "0010-01-28 00:01:00"),(155, "0010-01-28 00:01:00"),(156, "0010-01-28 00:01:01"),(157, "0010-01-28 00:01:01"),(158, "0010-01-28 00:01:01"),(159, "0010-01-28 00:01:59"),
      (160, "0010-01-28 00:01:59"),(161, "0010-01-28 00:01:59"),(162, "0010-01-28 00:59:00"),(163, "0010-01-28 00:59:00"),(164, "0010-01-28 00:59:00"),(165, "0010-01-28 00:59:01"),(166, "0010-01-28 00:59:01"),(167, "0010-01-28 00:59:01"),(168, "0010-01-28 00:59:59"),(169, "0010-01-28 00:59:59"),(170, "0010-01-28 00:59:59"),(171, "0010-01-28 01:00:00"),(172, "0010-01-28 01:00:00"),(173, "0010-01-28 01:00:00"),(174, "0010-01-28 01:00:01"),(175, "0010-01-28 01:00:01"),(176, "0010-01-28 01:00:01"),(177, "0010-01-28 01:00:59"),(178, "0010-01-28 01:00:59"),(179, "0010-01-28 01:00:59"),
      (180, "0010-01-28 01:01:00"),(181, "0010-01-28 01:01:00"),(182, "0010-01-28 01:01:00"),(183, "0010-01-28 01:01:01"),(184, "0010-01-28 01:01:01"),(185, "0010-01-28 01:01:01"),(186, "0010-01-28 01:01:59"),(187, "0010-01-28 01:01:59"),(188, "0010-01-28 01:01:59"),(189, "0010-01-28 01:59:00"),(190, "0010-01-28 01:59:00"),(191, "0010-01-28 01:59:00"),(192, "0010-01-28 01:59:01"),(193, "0010-01-28 01:59:01"),(194, "0010-01-28 01:59:01")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part3_3_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_3_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part3_3_nullable order by 1;'

    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part3_3_not_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part3_3_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part3_3_not_nullable values (0, "0001-12-28 00:59:00"),(1, "0001-12-28 00:59:00"),(2, "0001-12-28 00:59:00"),(3, "0001-12-28 00:59:01"),(4, "0001-12-28 00:59:01"),(5, "0001-12-28 00:59:01"),(6, "0001-12-28 00:59:59"),(7, "0001-12-28 00:59:59"),(8, "0001-12-28 00:59:59"),(9, "0001-12-28 01:00:00"),(10, "0001-12-28 01:00:00"),(11, "0001-12-28 01:00:00"),(12, "0001-12-28 01:00:01"),(13, "0001-12-28 01:00:01"),(14, "0001-12-28 01:00:01"),(15, "0001-12-28 01:00:59"),(16, "0001-12-28 01:00:59"),(17, "0001-12-28 01:00:59"),(18, "0001-12-28 01:01:00"),(19, "0001-12-28 01:01:00"),
      (20, "0001-12-28 01:01:00"),(21, "0001-12-28 01:01:01"),(22, "0001-12-28 01:01:01"),(23, "0001-12-28 01:01:01"),(24, "0001-12-28 01:01:59"),(25, "0001-12-28 01:01:59"),(26, "0001-12-28 01:01:59"),(27, "0001-12-28 01:59:00"),(28, "0001-12-28 01:59:00"),(29, "0001-12-28 01:59:00"),(30, "0001-12-28 01:59:01"),(31, "0001-12-28 01:59:01"),(32, "0001-12-28 01:59:01"),(33, "0001-12-28 01:59:59"),(34, "0001-12-28 01:59:59"),(35, "0001-12-28 01:59:59"),(36, "0001-12-28 23:00:00"),(37, "0001-12-28 23:00:00"),(38, "0001-12-28 23:00:00"),(39, "0001-12-28 23:00:01"),
      (40, "0001-12-28 23:00:01"),(41, "0001-12-28 23:00:01"),(42, "0001-12-28 23:00:59"),(43, "0001-12-28 23:00:59"),(44, "0001-12-28 23:00:59"),(45, "0001-12-28 23:01:00"),(46, "0001-12-28 23:01:00"),(47, "0001-12-28 23:01:00"),(48, "0001-12-28 23:01:01"),(49, "0001-12-28 23:01:01"),(50, "0001-12-28 23:01:01"),(51, "0001-12-28 23:01:59"),(52, "0001-12-28 23:01:59"),(53, "0001-12-28 23:01:59"),(54, "0001-12-28 23:59:00"),(55, "0001-12-28 23:59:00"),(56, "0001-12-28 23:59:00"),(57, "0001-12-28 23:59:01"),(58, "0001-12-28 23:59:01"),(59, "0001-12-28 23:59:01"),
      (60, "0001-12-28 23:59:59"),(61, "0001-12-28 23:59:59"),(62, "0001-12-28 23:59:59"),(63, "0010-01-01 00:00:00"),(64, "0010-01-01 00:00:00"),(65, "0010-01-01 00:00:00"),(66, "0010-01-01 00:00:01"),(67, "0010-01-01 00:00:01"),(68, "0010-01-01 00:00:01"),(69, "0010-01-01 00:00:59"),(70, "0010-01-01 00:00:59"),(71, "0010-01-01 00:00:59"),(72, "0010-01-01 00:01:00"),(73, "0010-01-01 00:01:00"),(74, "0010-01-01 00:01:00"),(75, "0010-01-01 00:01:01"),(76, "0010-01-01 00:01:01"),(77, "0010-01-01 00:01:01"),(78, "0010-01-01 00:01:59"),(79, "0010-01-01 00:01:59"),
      (80, "0010-01-01 00:01:59"),(81, "0010-01-01 00:59:00"),(82, "0010-01-01 00:59:00"),(83, "0010-01-01 00:59:00"),(84, "0010-01-01 00:59:01"),(85, "0010-01-01 00:59:01"),(86, "0010-01-01 00:59:01"),(87, "0010-01-01 00:59:59"),(88, "0010-01-01 00:59:59"),(89, "0010-01-01 00:59:59"),(90, "0010-01-01 01:00:00"),(91, "0010-01-01 01:00:00"),(92, "0010-01-01 01:00:00"),(93, "0010-01-01 01:00:01"),(94, "0010-01-01 01:00:01"),(95, "0010-01-01 01:00:01"),(96, "0010-01-01 01:00:59"),(97, "0010-01-01 01:00:59"),(98, "0010-01-01 01:00:59"),(99, "0010-01-01 01:01:00"),
      (100, "0010-01-01 01:01:00"),(101, "0010-01-01 01:01:00"),(102, "0010-01-01 01:01:01"),(103, "0010-01-01 01:01:01"),(104, "0010-01-01 01:01:01"),(105, "0010-01-01 01:01:59"),(106, "0010-01-01 01:01:59"),(107, "0010-01-01 01:01:59"),(108, "0010-01-01 01:59:00"),(109, "0010-01-01 01:59:00"),(110, "0010-01-01 01:59:00"),(111, "0010-01-01 01:59:01"),(112, "0010-01-01 01:59:01"),(113, "0010-01-01 01:59:01"),(114, "0010-01-01 01:59:59"),(115, "0010-01-01 01:59:59"),(116, "0010-01-01 01:59:59"),(117, "0010-01-01 23:00:00"),(118, "0010-01-01 23:00:00"),(119, "0010-01-01 23:00:00"),
      (120, "0010-01-01 23:00:01"),(121, "0010-01-01 23:00:01"),(122, "0010-01-01 23:00:01"),(123, "0010-01-01 23:00:59"),(124, "0010-01-01 23:00:59"),(125, "0010-01-01 23:00:59"),(126, "0010-01-01 23:01:00"),(127, "0010-01-01 23:01:00"),(128, "0010-01-01 23:01:00"),(129, "0010-01-01 23:01:01"),(130, "0010-01-01 23:01:01"),(131, "0010-01-01 23:01:01"),(132, "0010-01-01 23:01:59"),(133, "0010-01-01 23:01:59"),(134, "0010-01-01 23:01:59"),(135, "0010-01-01 23:59:00"),(136, "0010-01-01 23:59:00"),(137, "0010-01-01 23:59:00"),(138, "0010-01-01 23:59:01"),(139, "0010-01-01 23:59:01"),
      (140, "0010-01-01 23:59:01"),(141, "0010-01-01 23:59:59"),(142, "0010-01-01 23:59:59"),(143, "0010-01-01 23:59:59"),(144, "0010-01-28 00:00:00"),(145, "0010-01-28 00:00:00"),(146, "0010-01-28 00:00:00"),(147, "0010-01-28 00:00:01"),(148, "0010-01-28 00:00:01"),(149, "0010-01-28 00:00:01"),(150, "0010-01-28 00:00:59"),(151, "0010-01-28 00:00:59"),(152, "0010-01-28 00:00:59"),(153, "0010-01-28 00:01:00"),(154, "0010-01-28 00:01:00"),(155, "0010-01-28 00:01:00"),(156, "0010-01-28 00:01:01"),(157, "0010-01-28 00:01:01"),(158, "0010-01-28 00:01:01"),(159, "0010-01-28 00:01:59"),
      (160, "0010-01-28 00:01:59"),(161, "0010-01-28 00:01:59"),(162, "0010-01-28 00:59:00"),(163, "0010-01-28 00:59:00"),(164, "0010-01-28 00:59:00"),(165, "0010-01-28 00:59:01"),(166, "0010-01-28 00:59:01"),(167, "0010-01-28 00:59:01"),(168, "0010-01-28 00:59:59"),(169, "0010-01-28 00:59:59"),(170, "0010-01-28 00:59:59"),(171, "0010-01-28 01:00:00"),(172, "0010-01-28 01:00:00"),(173, "0010-01-28 01:00:00"),(174, "0010-01-28 01:00:01"),(175, "0010-01-28 01:00:01"),(176, "0010-01-28 01:00:01"),(177, "0010-01-28 01:00:59"),(178, "0010-01-28 01:00:59"),(179, "0010-01-28 01:00:59"),
      (180, "0010-01-28 01:01:00"),(181, "0010-01-28 01:01:00"),(182, "0010-01-28 01:01:00"),(183, "0010-01-28 01:01:01"),(184, "0010-01-28 01:01:01"),(185, "0010-01-28 01:01:01"),(186, "0010-01-28 01:01:59"),(187, "0010-01-28 01:01:59"),(188, "0010-01-28 01:01:59"),(189, "0010-01-28 01:59:00"),(190, "0010-01-28 01:59:00"),(191, "0010-01-28 01:59:00"),(192, "0010-01-28 01:59:01"),(193, "0010-01-28 01:59:01"),(194, "0010-01-28 01:59:01");
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part3_3_not_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_3_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part3_3_not_nullable order by 1;'

}